CREATE TABLE `SRAnalytics`.`MsgLiveExpirySurface` (
`ekey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None',
`ekey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None',
`ekey_tk` VARCHAR(12) NOT NULL DEFAULT '',
`ekey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
`ekey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`ekey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`surfaceType` ENUM('None','Live','PrevDay','Interp','Close','Test') NOT NULL DEFAULT 'None',
`uPrc` DOUBLE NOT NULL DEFAULT 0 COMMENT 'effective uPrc used for surface fitting',
`uPrcDriver` DOUBLE NOT NULL DEFAULT 0 COMMENT 'underlier driver (mid-market)',
`iDays` INT NOT NULL DEFAULT 0 COMMENT 'interest days to expiry',
`years` FLOAT NOT NULL DEFAULT 0 COMMENT 'volatility time to expiration (in years)',
`rate` FLOAT NOT NULL DEFAULT 0 COMMENT 'term interest rate to expiry (discount rate)',
`atmVol` FLOAT NOT NULL DEFAULT 0 COMMENT 'atm surface volatility (xAxis = 0)',
`atmCen` FLOAT NOT NULL DEFAULT 0 COMMENT 'censored atm surface volatility (xAxis = 0)',
`atmSlope` FLOAT NOT NULL DEFAULT 0 COMMENT 'volatility surface slope (dVol / dXAxis) (xAxis=0)',
`atmSkewYY` FLOAT NOT NULL DEFAULT 0 COMMENT 'skewFn @ xAxis = 0 (sticky surface static point)',
`atmVResidual` FLOAT NOT NULL DEFAULT 0 COMMENT 'vResidual @ xAxis = 0 (sticky surface static point)',
`atmSDiv` FLOAT NOT NULL DEFAULT 0 COMMENT 'atm continous stock dividend (borrow rate) (xAxis = 0)',
`basisEKey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'LiveBasisCurve.pkey.ekey record that defines BasisSkewFn below.',
`basisEKey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'LiveBasisCurve.pkey.ekey record that defines BasisSkewFn below.',
`basisEKey_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'LiveBasisCurve.pkey.ekey record that defines BasisSkewFn below.',
`basisEKey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'LiveBasisCurve.pkey.ekey record that defines BasisSkewFn below.',
`basisEKey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'LiveBasisCurve.pkey.ekey record that defines BasisSkewFn below.',
`basisEKey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'LiveBasisCurve.pkey.ekey record that defines BasisSkewFn below.',
`basisTimestamp` DATETIME(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000' COMMENT 'LiveBasisCurve.timestamp',
`axisFUPrc` FLOAT NOT NULL DEFAULT 0 COMMENT 'axis FwdUPrc (fwd underlying price used to compute xAxis)',
`axisVolRT` FLOAT NOT NULL DEFAULT 0 COMMENT 'axis VolRT value used to compute xAxis (usually equal to skewMult) (value at curve min point)',
`xMult` FLOAT NOT NULL DEFAULT 0,
`xShift` FLOAT NOT NULL DEFAULT 0,
`skewMult` FLOAT NOT NULL DEFAULT 0 COMMENT 'sVol = skewMult * BasisSkewFn(xMult * (xAxis - xShift))',
`maxResidualErr` FLOAT NOT NULL DEFAULT 0 COMMENT 'largest remain residual error (in premium points)',
`cpAdjA` FLOAT NOT NULL DEFAULT 0 COMMENT 'cpAdj = cpAdjA + cpXDe * cpAdjB + cpXDe * cpXDe * cpAdjC [cpAdj is either sdiv or uPrcRatio]',
`cpAdjB` FLOAT NOT NULL DEFAULT 0,
`cpAdjC` FLOAT NOT NULL DEFAULT 0,
`cpAdjRefVol` FLOAT NOT NULL DEFAULT 0 COMMENT 'cpXDe = 0.5 - BS_cDe(uPrc, strike, cpAdjRefVol, years, rate, sdiv=0)',
`ticker_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'underlying stock key that this option expiration attaches to',
`ticker_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'underlying stock key that this option expiration attaches to',
`ticker_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'underlying stock key that this option expiration attaches to',
`fkey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'underlying future key (if any)',
`fkey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'underlying future key (if any)',
`fkey_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'underlying future key (if any)',
`fkey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'underlying future key (if any)',
`fkey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'underlying future key (if any)',
`fkey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'underlying future key (if any)',
`uPrcDriverKey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'underlier driver key',
`uPrcDriverKey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'underlier driver key',
`uPrcDriverKey_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'underlier driver key',
`uPrcDriverKey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'underlier driver key',
`uPrcDriverKey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'underlier driver key',
`uPrcDriverKey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'underlier driver key',
`uPrcDriverType` ENUM('None','Stock','Future','Option','MLeg') NOT NULL DEFAULT 'None' COMMENT 'underlier driver key type (stock or future)',
`ddiv` FLOAT NOT NULL DEFAULT 0 COMMENT '(expected) cumulative discrete dividend $ amounts prior to expiration',
`ddivPv` FLOAT NOT NULL DEFAULT 0 COMMENT '(expected) cumulative npv of discrete dividend $ amounts prior to expiration (SR global rate curve)',
`ddivSource` ENUM('None','Announced','Forecast') NOT NULL DEFAULT 'None' COMMENT 'Forecast if any of the dividends prior to expiry are forecast rather than announced',
`symbolRatio` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier price ratio (usually 1.0 or a multi-hedge option price ratio; if one exists)',
`exType` ENUM('None','American','European','Asian','Cliquet') NOT NULL DEFAULT 'None' COMMENT 'exercise type (American or European)',
`modelType` ENUM('None','LogNormalExact','NormalExact','LogNormalApprox','NormalApprox') NOT NULL DEFAULT 'None' COMMENT 'option pricing model used for price calcs (Normal, LogNormal, etc.)',
`priceType` ENUM('None','Equity','Future') NOT NULL DEFAULT 'None' COMMENT 'Equity has independent sdiv and rate, Future has sdiv = rate',
`earnCnt` FLOAT NOT NULL DEFAULT 0 COMMENT 'number of qualifying earnings events prior to expiration [can be fractional] (from StockEarningsCalendar)',
`earnCntAdj` FLOAT NOT NULL DEFAULT 0 COMMENT 'number of qualifying earnings events prior to expiration [adjusted] (from StockEarningsCalendar + LiveSurfaceTerm)',
`moneynessType` ENUM('None','PctStd','LogStd','NormStd') NOT NULL DEFAULT 'None' COMMENT 'moneyness (xAxis) convention',
`priceQuoteType` ENUM('None','Price','Vol') NOT NULL DEFAULT 'None' COMMENT 'Price or Vol',
`atmVolHist` FLOAT NOT NULL DEFAULT 0 COMMENT 'historical realized volatility (includes eMoveHist x earnCntAdj adjustment). Note that this is the default atmVol if no implied markets existed previous day.',
`atmCenHist` FLOAT NOT NULL DEFAULT 0 COMMENT 'censored (earnings events removed) historical realized volatility. Trailing periods is 2x forward time to expiration. From HistoricalVolatility(windowType=hlCen).mv_nnn',
`uBetaHist` FLOAT NOT NULL DEFAULT 0 COMMENT 'beta (this underlier vs basis underlier; T + 1 week)',
`eMove` FLOAT NOT NULL DEFAULT 0 COMMENT 'implied earnings move (from LiveSurfaceTerm)',
`eMoveHist` FLOAT NOT NULL DEFAULT 0 COMMENT 'historical earnings move (avg of trailing 8 moves). From StockEarningsCalendar.eMoveHist',
`minXAxis` FLOAT NOT NULL DEFAULT 0 COMMENT 'minimum xAxis value; left most point with a valid supporting strike',
`maxXAxis` FLOAT NOT NULL DEFAULT 0 COMMENT 'maximum xAxis value; right most point with a valid supporting strike',
`synSpot` FLOAT NOT NULL DEFAULT 0 COMMENT 'synthetic spot price (future style pricing)',
`synCarry` FLOAT NOT NULL DEFAULT 0 COMMENT 'synthetic carry rate (future style pricing)',
`uPrcRatio` DOUBLE NOT NULL DEFAULT 0 COMMENT 'uPrcAdj = uPrc * uPrcRatioFit',
`pWidth` FLOAT NOT NULL DEFAULT 0 COMMENT 'minimum mkt premium width',
`vWidth` FLOAT NOT NULL DEFAULT 0 COMMENT 'minimum mkt volatility width',
`cCnt` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'num call strikes in base fit',
`pCnt` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'num put strikes in base fit',
`hasBracketMin` ENUM('None','Yes','No') NOT NULL DEFAULT 'None',
`hasMinPoint` ENUM('None','Yes','No') NOT NULL DEFAULT 'None',
`hasXMultABFit` ENUM('None','Yes','No') NOT NULL DEFAULT 'None',
`xMultABFitError` DOUBLE NOT NULL DEFAULT 0,
`hasSkewMultFit` ENUM('None','Yes','No') NOT NULL DEFAULT 'None',
`skewMultFitError` DOUBLE NOT NULL DEFAULT 0,
`cBidMiss` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'number of call bid violations (surface outside the market)',
`cAskMiss` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'number of call ask violations (surface outside the market)',
`pBidMiss` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'number of put bid violations',
`pAskMiss` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'number of put ask violations',
`fitScore` FLOAT NOT NULL DEFAULT 0,
`cumFitScore` FLOAT NOT NULL DEFAULT 0,
`numPrintsDD` INT NOT NULL DEFAULT 0 COMMENT 'cpXDe < -0.45',
`avgPrtErrDD` FLOAT NOT NULL DEFAULT 0 COMMENT 'avg: prtPrc - surfacePrc (AUTO ONLY)',
`stdPrtErrDD` FLOAT NOT NULL DEFAULT 0 COMMENT 'std: prtPrc - surfacePrc (AUTO ONLY)',
`numPrintsDN` INT NOT NULL DEFAULT 0 COMMENT 'cpXDe: [-0.45, -0.15)',
`avgPrtErrDN` FLOAT NOT NULL DEFAULT 0,
`stdPrtErrDN` FLOAT NOT NULL DEFAULT 0,
`numPrintsAT` INT NOT NULL DEFAULT 0 COMMENT 'cpXDe: [-0.15, +0.15]',
`avgPrtErrAT` FLOAT NOT NULL DEFAULT 0,
`stdPrtErrAT` FLOAT NOT NULL DEFAULT 0,
`numPrintsUP` INT NOT NULL DEFAULT 0 COMMENT 'cpXDe: (+0.15, +0.45]',
`avgPrtErrUP` FLOAT NOT NULL DEFAULT 0,
`stdPrtErrUP` FLOAT NOT NULL DEFAULT 0,
`numPrintsDU` INT NOT NULL DEFAULT 0 COMMENT 'cpXDe > +0.45',
`avgPrtErrDU` FLOAT NOT NULL DEFAULT 0,
`stdPrtErrDU` FLOAT NOT NULL DEFAULT 0,
`fitCounter` INT NOT NULL DEFAULT 0 COMMENT 'number of fit/count passes (current trade date / market open)',
`tradeableStatus` ENUM('None','OK','SurfaceErr','LowCCnt','LowPCnt','FitPrcErr','BidAskMiss','LowCounter','DefaultSkew','SessionMiss','BaseErr','SwitchDelay','WideMktV','WideMktP','WideUMkt','UWidthEma','CCntEma','PCntEma','VWidthEma','PWidthEma','Closed') NOT NULL DEFAULT 'None' COMMENT 'indicates whether the surface is currently tradeable or not (all server surface integrity checks pass)',
`marketPhase` ENUM('None','BeforeEarlyPreOpen','EarlyPreOpen','EarlySession','BeforeRegPreOpen','RegPreOpen','RegSession','BeforeLatePreOpen','LatePreOpen','LateSession','MarketClosed','Cooldown','Rotation','Warmup') NOT NULL DEFAULT 'None' COMMENT 'market phase this surface is from',
`surfaceFitResult` ENUM('None','OK','OptMktClosed','NoBasisFn','NoCPItems') NOT NULL DEFAULT 'None',
`timestamp` DATETIME(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000',
`ResidualList` JSON NOT NULL DEFAULT JSON_ARRAY() CHECK(JSON_VALID(ResidualList)),
PRIMARY KEY USING HASH (`ekey_tk`,`ekey_yr`,`ekey_mn`,`ekey_dy`,`ekey_at`,`ekey_ts`,`surfaceType`)
) ENGINE=SRSE DEFAULT CHARSET=LATIN1 COMMENT='LiveExpirySurface (surfaceType = \'Live\') records are computed and publish continuously during trading hours and represent a current best implied volatility market fit.\nSurfaceType = \'PriorDay\' records contain the `closing surface record from the prior trading period (usually from just before the last main session close).';